<?php
namespace app\common\validate;
use app\validate\Common;
use think\Validate;

class User extends Common
{
	/*验证规则*/
	protected $rule = [
		'username'		=> 'require',
		'sex'			=> 'require|in:0,1,2',
		'phone'			=> 'require|regex:phone',
		'age'			=> 'require|between:1,150',
	];
	/*验证提示信息*/
	protected $message = [
		'username.require'		=> '客户姓名不能为空',
		'sex.require'			=> '客户性别不能为空',
		'sex.in'				=> '客户性别格式错误',
		'phone.require'			=> '联系电话不能为空',
		'phone.regex'			=> '联系电话格式错误',
		'age.require'			=> '客户年龄不能为空',
		'age.between'			=> '客户年龄格式错误',
	];
	/*验证场景*/
	protected $scene = [
		'edit'	=> ['username','sex','phone','age'],
		'add'	=> ['user_sn','username','phone'],
	];
}